﻿using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.IdentityModel.Tokens;
using OpenIddict.Server.AspNetCore;
using static OpenIddict.Abstractions.OpenIddictConstants;
using System.Security.Claims;
using OpenIddict.Abstractions;

namespace Demo.Net.OpenIddict.Controllers
{
    [Route("api/[controller]")]
    [ApiController]

    [Authorize]
    public class AuthController : ControllerBase
    {

        [HttpPost("~/connect/token"), IgnoreAntiforgeryToken, Produces("application/json")]
        public async Task<IActionResult> Exchange()
        {

            return Ok();
            //var descriptor = new OpenIddictTokenDescriptor
            //{
            //    Subject = User.FindFirst(ClaimTypes.NameIdentifier)?.Value,
            //    TokenType = OpenIddictConstants.TokenType.AccessToken,
            //    ClientId = "your_client_id",
            //    // Add any other necessary properties to the token descriptor
            //};

            //var token = await _tokenManager.CreateAsync(descriptor);

            //return Ok(new
            //{
            //    access_token = token,
            //    token_type = "Bearer"
            //    // include other token response properties as needed
            //});
        }
    }
}
